package com.windward.vii.dao.mapper;

import com.windward.vii.dao.entity.UserContent;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface UserContentMapper {
    @Delete({
        "delete from user_content",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long id);

    @Insert({
        "insert into user_content (id, uid, title, ",
        "images, create_time, ",
        "update_time, is_review, ",
        "review_result, is_exist_illegal)",
        "values (#{id,jdbcType=BIGINT}, #{uid,jdbcType=BIGINT}, #{title,jdbcType=VARCHAR}, ",
        "#{images,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{updateTime,jdbcType=TIMESTAMP}, #{isReview,jdbcType=BIT}, ",
        "#{reviewResult,jdbcType=VARCHAR}, #{isExistIllegal,jdbcType=BIT})"
    })
    int insert(UserContent record);

    int insertSelective(UserContent record);

    @Select({
        "select",
        "id, uid, title, images, create_time, update_time, is_review, review_result, ",
        "is_exist_illegal",
        "from user_content",
        "where id = #{id,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    UserContent selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(UserContent record);

    @Update({
        "update user_content",
        "set uid = #{uid,jdbcType=BIGINT},",
          "title = #{title,jdbcType=VARCHAR},",
          "images = #{images,jdbcType=VARCHAR},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "update_time = #{updateTime,jdbcType=TIMESTAMP},",
          "is_review = #{isReview,jdbcType=BIT},",
          "review_result = #{reviewResult,jdbcType=VARCHAR},",
          "is_exist_illegal = #{isExistIllegal,jdbcType=BIT}",
        "where id = #{id,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(UserContent record);

    /***********以下为自定义方法************************/

    @Select({
            "select * ",
            "from user_content",
            "where uid = #{uid,jdbcType=BIGINT} order by create_time desc"
    })
    @ResultMap("BaseResultMap")
    List<UserContent> getContentListByUid(Long uid);
}